﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using VOL.Core.Utilities;
using VOL.Entity.DomainModels;
using VOL.Team.TeamIServices.ProductManagement.IServices;

namespace VOL.WebApi.Controllers.Team.xzc
{
    /// <summary>
    /// 产品管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProductManagementController : ControllerBase
    {
        /// <summary>
        /// 产品维护 
        /// </summary>
        private readonly IProductMaintenanceServices _productMaintenanceServices;

        public ProductManagementController(IProductMaintenanceServices productMaintenanceServices)
        {
            _productMaintenanceServices = productMaintenanceServices;
        }
        /// <summary>
        /// 查询产品维护
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public WebResponseContent GetProductMaintenance(string? qecode, string? bomcode, string? productcode)
        {
            WebResponseContent webResponseContent = new WebResponseContent();
            var productmaintenanceList = _productMaintenanceServices.GetProductMaintenance(qecode, bomcode, productcode);
            return webResponseContent.OK("查询产品维护成功", productmaintenanceList);
        }
        /// <summary>
        /// 新增产品维护
        /// </summary>
        /// <param name="productmaintenance"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<WebResponseContent> AddProductMaintenance([FromBody] ProductMaintenance productmaintenance)
        {
            WebResponseContent webResponseContent = new WebResponseContent();
            var productmaintenanceList = await _productMaintenanceServices.AddProductMaintenance(productmaintenance);
            return webResponseContent.OK("新增产品维护成功", productmaintenanceList);
        }
        /// <summary>
        /// 更新产品维护
        /// </summary>
        /// <param name="productmaintenance"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<WebResponseContent> UpdateProductMaintenance([FromBody] ProductMaintenance productmaintenance)
        {
            WebResponseContent webResponseContent = new WebResponseContent();
            var productmaintenanceList = await _productMaintenanceServices.UpdateProductMaintenance(productmaintenance);
            return webResponseContent.OK("更新产品维护成功", productmaintenanceList);
        }
        /// <summary>
        /// 删除产品维护
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<WebResponseContent> DeleteProductMaintenance(int id)
        {
            WebResponseContent webResponseContent = new WebResponseContent();
            var productmaintenanceList = await _productMaintenanceServices.DeleteProductMaintenance(id);
            return webResponseContent.OK("删除产品维护成功", productmaintenanceList);
        }
        /// <summary>
        /// 批量删除产品维护
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<WebResponseContent> DeleteAnageProductMaintenance(string Id)
        {
            WebResponseContent webResponseContent = new WebResponseContent();
            var productmaintenanceList = await _productMaintenanceServices.DeleteAnageProductMaintenance(Id);
            return webResponseContent.OK("批量删除产品维护成功", productmaintenanceList);
        }
    }
}
